package com.twu.biblioteca;

import java.util.List;

/**
 * Created by utsabban on 3/2/14.
 */
public class CustomerDB {
    private List<String> customerNameList;
    private List<String> customerNumberList;
    private List<String> passwordList;
    private List<String> emailIDList;
    private List<String> mobileNOList;

    public CustomerDB(List<String> customerNameList, List<String> customerNumberList, List<String> passwordList, List<String> emailIDList, List<String> mobileNOList) {
        this.customerNameList = customerNameList;
        this.customerNumberList = customerNumberList;
        this.passwordList = passwordList;
        this.emailIDList = emailIDList;
        this.mobileNOList = mobileNOList;
    }

    public Integer verifyCustomerAndReturnIndexInCustomerDB(String customerNumber,String password){
        Integer verifiedUserDataIndexInCustomerDB=null;
        int indexOfCurrentCustomerInCustomerDB=customerNumberList.indexOf(customerNumber);

        if(indexOfCurrentCustomerInCustomerDB!=-1)
        {
            String passwordAtTheIndexOfCurrentCustomerInCustomerDB=passwordList.get(indexOfCurrentCustomerInCustomerDB);
            if(password.equals(passwordAtTheIndexOfCurrentCustomerInCustomerDB))
                verifiedUserDataIndexInCustomerDB=indexOfCurrentCustomerInCustomerDB;
        }
        return verifiedUserDataIndexInCustomerDB;
    }

    public String displayVerifiedUserInformation(int verifiedUserDataIndexInCustomerDB) {
        try {
        return "Customer Information" +
                "\ncustomerName = " + customerNameList.get(verifiedUserDataIndexInCustomerDB) +
                "\nemailIDList = " + emailIDList.get(verifiedUserDataIndexInCustomerDB) +
                "\nmobileNOList = " + mobileNOList.get(verifiedUserDataIndexInCustomerDB) +
                "\n";
        }
        catch (IndexOutOfBoundsException e)
        {
            return "InvalidVerifiedUserDataIndexInCustomerDB";
        }
    }
}
